﻿@model WebCalendar.Models.DTOs.ManageIndexDTO

@{
    ViewBag.Title = "List";
}

<h2>Your own calendars</h2>
<table>
    <tr>
        <th></th>
        <th>Name</th>
        <th>Appointments</th>
        <th style="width:80px; text-align:center;" >Public</th>
        <th>Action</th>
    </tr>
@foreach (var item in Model.OwnCalendars)
{
    <tr>
        <td>
            <a href="@Url.Action( "Index", "Calendar", new { id = item.ID, year = DateTime.Now.Year, month = DateTime.Now.Month })">
                <img src="~/Images/calendar.png" style="height:30px;" />
            </a>
        </td>
        <td>
            <a href="@Url.Action( "Index", "Calendar", new { id = item.ID, year = DateTime.Now.Year, month = DateTime.Now.Month })">@item.Name</a>
        </td>
        <td>
            <a href="@Url.Action( "Index", "Appointment", new { id = item.ID, year = DateTime.Now.Year, month = DateTime.Now.Month })">Show appointment requests</a>
        </td>
        <td style="text-align:center;">
             @Html.CheckBoxFor(m => item.IsPublic, new { @disabled="disabled" })
        </td>
        <td>
            @if(!item.IsPublic){
                using (Html.BeginForm("Publish", "Calendar", new { id = item.ID }, FormMethod.Post))
                {
                    <button type="submit">Publish</button>
                }
            }else{
                using (Html.BeginForm("Unpublish", "Calendar", new { id = item.ID }, FormMethod.Post))
                {
                    <button type="submit">Unpublish</button>
                }
            }
        </td>
    </tr>
}
</table>